const app = getApp();
import { request, toast } from './../../utils/index.js';
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
import Notify from '../../miniprogram_npm/@vant/weapp/notify/notify.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    prolist: '', // 异常订单
    invoiceHeader: '', // 分仓
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('异常')
    const token = wx.getStorageSync('token')
    const delivery = wx.getStorageSync('name')
    try {
      request({
        url: '/getOrderDeliveryAbnormalList',
        method: 'GET',
        data: {
          token,
          delivery
        },
        header: {
          'content-type': 'application/json',
          'token': `${token}`
        }
      }).then(res => {
        // Toast.success('您已上班');
        if(res.data.code == 200) {
          const result = res.data.result.orderDeliveryAbnormalList
          console.log('res',res.data.result.orderDeliveryAbnormalList.length)
          if(res.data.result.orderDeliveryAbnormalList.length > 0) {
            result.forEach((item,index) => {
              if(result[index].deliveryStartTime !== undefined) {
                result[index].StartTime = result[index].deliveryStartTime.substring(5,16)
                result[index].EndTime = result[index].deliveryEndTime.substring(11,16)
              }
              // result[index].invoiceHeader = result.deliveryStartTime.substring(5,15)
            })
          }
          this.setData({
            prolist: result,
            // invoiceHeader: res.data.result.orderDeliveryAbnormalList[0].invoiceHeader
          })
        } else {
          Notify({
            message: `${res.data.msg}`,
            type: 'danger'
          })
        }
      })
    } catch (error) {
      
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})